package Clases;

public class Integrar {
	private float _ax;
	private float _ay;
	private float _az;
	private float _vx;
	private float _vy;
	private float _vz;
	private float _sx;
	private float _sy;
	private float _sz;
	
	public Integrar(){
		_ax = _ay = _az = (float)0.0;
		_vx = _vy = _vz = (float)0.0;
		_sx = _sy = _sz = (float)0.0;
	}
	
	public float integrarX(float t, float axFiltro){
		//Cálculo de la velocidad
		float speed = (float) (_vx + ((axFiltro + _ax) * t / 2. ));
		//calculo el espacio
	    float space=  (float) (_sx + (t * (speed - _vx ) / 2.) + _vx *t);
	    
	    _ax = axFiltro;
	    _vx = speed;
	    _sx = space;
	    return space;
	}
	
	public float integrarY(float t, float ayFiltro){
		//Cálculo de la velocidad
		float speed = (float) (_vy + ((ayFiltro + _ay) * t / 2. ));
		//calculo el espacio
	    float space=  (float) (_sy + (t * (speed - _vy ) / 2.) + _vy *t);
	    
	    _ay = ayFiltro;
	    _vy = speed;
	    _sy = space;
	    return space;
	}
	
	public float integrarZ(float t, float azFiltro){
		//Cálculo de la velocidad
		float speed = (float) (_vz + ((azFiltro + _az) * t / 2. ));
		//calculo el espacio
	    float space=  (float) (_sz + (t * (speed - _vz ) / 2.) + _vz *t);
	    
	    _az = azFiltro;
	    _vz = speed;
	    _sz = space;
	    return space;
	}
}
